package com.neusoft.neumooc.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.neusoft.core.common.BaseService;
import com.neusoft.core.common.exception.ServiceException;
import com.neusoft.core.util.IDUtil;
import com.neusoft.neumooc.VO.OrderVO;
import com.neusoft.neumooc.dao.OrderDAO;


/** 
 * @ClassName: OrderServiceImpl 
 * @Description: TODO 订单管理业务逻辑处理类
 * @author zls
 * @date 2016年11月1日
 */
@Service
@Transactional
public class OrderServiceImpl extends BaseService implements OrderService{
	
	/** 
	 * @Fields orderDAO : TODO 订单管理业务数据访问类
	 */ 
	@Autowired
	OrderDAO orderDAO;
	
	
	/** 
	 * @Title: getOrderList 
	 * @Description: TODO 获得订单列表
	 * @param pageIndex 起始页数
	 * @param pageSize 页面大小
	 * @return List
	 * @throws ServiceException
	 */
	@Override
	public List<OrderVO> getOrderList(int pageIndex, int pageSize)
			throws ServiceException {
		return orderDAO.getOrderList(pageIndex,pageSize);
	}

	
	/** 
	 * @Title: getOrderNum 
	 * @Description: TODO 获得订单列表计数
	 * @return int
	 * @throws ServiceException
	 */
	@Override
	public int getOrderNum() throws ServiceException {
		return orderDAO.getOrderNum();
	}

	
	/** 
	 * @Title: changeOrderPay 
	 * @Description: TODO 更改订单支付状态
	 * @param orderId 订单ID
	 * @return int
	 * @throws ServiceException
	 */
	@Override
	public int changeOrderPay(String orderId) throws ServiceException {
		return orderDAO.changeOrderPay(orderId);
	}

	
	/** 
	 * @Title: changeOrderStatus 
	 * @Description: TODO 更改订单发货状态
	 * @param orderId 订单ID
	 * @return int
	 * @throws ServiceException
	 */
	@Override
	public int changeOrderStatus(String orderId) throws ServiceException {
		return orderDAO.changeOrderStatus(orderId);
	}

	
	/** 
	 * @Title: deleteOrder 
	 * @Description: TODO 删除订单
	 * @param orderId 订单ID
	 * @return int
	 * @throws ServiceException
	 */
	@Override
	public int deleteOrder(String orderId) throws ServiceException {
		return orderDAO.deleteOrder(orderId);
		
	}


	/** 
	 * @Title: addOrder 
	 * @Description: TODO 增加订单
	 * @param ordervo 订单实体
	 * @return int
	 * @throws ServiceException
	 */
	@Override

	public int addOrder(OrderVO orderVO) throws ServiceException {
	    orderVO.setId(IDUtil.getID());
		orderVO.setOrderId(IDUtil.getID());
		return orderDAO.addOrder(orderVO);

	}

}
